import QtQuick 2.9
import Qt.labs.lottieqt 1.0

Rectangle {
    id: root
    width: 640
    height: 480
    property bool selected: false

    LottieAnimation {
        id: lottieAnimation
        anchors.centerIn: parent
        scale: 0.4
        autoPlay: false
//        source: "lottie:rect_rotate.json"

        onFinished: {
            if(root.selected){
                lottieAnimation.start();
            }
        }
    }   

    MouseArea {
        anchors.fill: parent
        id:mouseArea

        onPressAndHold:{
            lottieAnimation.play();
            root.selected = !root.selected
        }

        onReleased: {
            root.selected =false
        }

    }
}
